package com.imooc.pan.server.modules.user.converter;

import com.imooc.pan.server.modules.file.entity.RPanUserFile;
import com.imooc.pan.server.modules.user.context.*;
import com.imooc.pan.server.modules.user.entity.RPanUser;
import com.imooc.pan.server.modules.user.po.*;
import com.imooc.pan.server.modules.user.vo.UserInfoVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * @author hhb
 * 用户模块实体转化工具类
 * @data 2024/6/7 16:19
 */
@Mapper(componentModel = "spring")
public interface UserConverter {
    /**
     * UserRegisterPO转化为UserRegisterContext
     * @param userRegisterPO
     * @return
     */
    UserRegisterContext userRegisterPOToUserRegisterContext(UserRegisterPO userRegisterPO);



    /**
     * UserRegisterContext转化为RPanUser
     * @param userRegisterContext
     * @return
     */
    @Mapping(target = "password",ignore = true)
    RPanUser userRegisterContextToRPanUser(UserRegisterContext userRegisterContext);


    /**
     * UserLoginPO转化为UserLoginContext
     * @param userLoginPO
     * @return
     */
    UserLoginContext userLoginPOToUserLoginContext(UserLoginPO userLoginPO);


    /**
     * CheckUserNamePO转化为CheckUserNameContext
     * @param checkUserNamePO
     * @return
     */
    CheckUserNameContext checkUserNamePOTOCheckUserNameContext(CheckUserNamePO checkUserNamePO);


    /**
     * CheckAnswerPO转化为CheckAnswerContext
     * @param checkAnswerPO
     * @return
     */
    CheckAnswerContext checkAnswerPOToCheckAnswerContext(CheckAnswerPO checkAnswerPO);

    /**
     * ResetPasswordPo转化为ResetPasswordContext
     * @param resetPasswordPo
     * @return
     */
    ResetPasswordContext resetPasswordPoToResetPasswordContext(ResetPasswordPo resetPasswordPo);

    /**
     * ChangePasswordPO转化为ChangePasswordContext
     * @param changePasswordPO
     * @return
     */
    ChangePasswordContext changePasswordPOToChangePasswordContext(ChangePasswordPO changePasswordPO);


    @Mapping(source = "rPanUser.username",target = "username")
    @Mapping(source = "rPanUserFile.fileId",target = "rootFileId")
    @Mapping(source = "rPanUserFile.filename",target = "rootFileName")
    UserInfoVo assembleUserInfoVO(RPanUser rPanUser, RPanUserFile rPanUserFile);

}
